import {
  getData,
  postData,
  putData,
  deleteData,
} from "@/api/common/index";

const baseUserTopConfigInfo = "/api/user-top-config-info";

const UserTopConfigInfoUrl = {
  page: "/page",
  url: "",
};

export function getUserTopConfigInfoPage(params: any, pageNo: number | null | undefined, pageSize : number | null| undefined): Promise<any> {
  let url = baseUserTopConfigInfo + UserTopConfigInfoUrl.page + "?pageNum=" + (pageNo ? pageNo : 1) + "&pageSize=" + (pageSize ? pageSize : 10);
  return postData(url, params);
}

export function getUserTopConfigInfoDetail(id: number): Promise<any> {
  return getData(baseUserTopConfigInfo + UserTopConfigInfoUrl.url + "?id=" + id);
}

export function deleteUserTopConfigInfo(ids: string) : Promise<any>{
  return deleteData(baseUserTopConfigInfo + UserTopConfigInfoUrl.url + "?ids=" + ids);
}

export function addOrEditUserTopConfigInfo(
  method: string,
  params: any
): Promise<any> {
  if ("put" == method) {
    return putData(baseUserTopConfigInfo + UserTopConfigInfoUrl.url, params);
  } else {
    return postData(baseUserTopConfigInfo +  UserTopConfigInfoUrl.url, params);
  }
}
